#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
class Point{
public:
    Point(float x=0,float y=0)
    :_x(x)
    ,_y(y){}
    friend class Line;
private:
    float _x;
    float _y;
};
class Color{
public:
    Color()
    :color(new char[1]())
    {}
    Color(const char * c)
    :color(new char[strlen(c)+ 1]())
    {
        strcpy(color,c);
    }
    Color(const Color & rhs)
    :color(new char[strlen(rhs.color) +1]())
    {
        strcpy(color,rhs.color);
    }
    Color & operator=(const Color & rhs)
    {
        if(this != &rhs){
           delete [] color;
           color = new char[strlen(rhs.color)+1]();
           strcpy(color,rhs.color);
        }
        return *this;
    }
friend class Triangle;
private:
    char * color;
};
class Line{
public:
    Line()
    {}
    Line(float x,float y,float x1, float y1)
    :p1(x,y)
    ,p2(x1,y1)
    {}
    float getLine(){
        return  sqrt(pow((p2._x - p1._x),2) + pow((p2._y - p1._y),2));
    }
private:
    Point p1;
    Point p2;
};
class Triangle : public Line,
                 public Color
{
public:
    Triangle(float x ,float y ,float x1,float y1,float height, const char * scolor)
    :Line(x,y,x1,y1)
    ,color(scolor)
    ,height(height){}
      void getTriangleArea(){
      float lines = getLine();
      float Area = lines * height * 0.5;
      float perimeter = sqrt(pow(height,2) + pow(lines,2)) + lines + height;
      cout << "三角形面积 "<<Area<<endl;
      cout<<"三角形周长 "<< perimeter<<endl;
      cout<<"三角形颜色 "<<color.color <<endl;
    }
private:
    float height;
    Color color;
    Line line;
};
void test(){
  Triangle tr(0,0,0,3,4,"white");
  tr.getTriangleArea();
}
int main()
{
    test();
    return 0;
}

